<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LaySNS安装程序</title>
<script type="text/javascript" src="./js/jquery.js"></script>
<link rel="stylesheet" href="./css/install.css">  
<link rel="stylesheet" href="./css/multi-steps.css">
</head>
<body>
<div class="wrap">
  <div class="header">
      LAYSNS <?php echo VERSION;?> 安装向导
</div>  
<div class="blank10"></div>
<nav>
		<ol class="cd-multi-steps text-bottom count">
			<li class="visited"><a href="#0">使用协议</a></li>
			<li class="visited" ><a href="#0">检查环境</a></li>
			<li class="current"><em>配置系统</em></li>
			<li><em>完成安装</em></li>
		</ol>
	</nav>
<section class="section">
    <div class="blank20"></div>
    <form action="./index.php?c=success" method="post">
      <input type="hidden" name="force" value="0" />
      <div class="server">
        <table width="100%" id="table" border="0" cellspacing="1" cellpadding="4">
          <tr>
            <td class="td1" colspan="2">数据库信息</td>
          </tr>
      <tr>
            <td class="tar">数据库地址</td>
            <td><input type="text" name="DB_HOST" value="localhost" required lay-verify="required" autocomplete="off" class="input"><div id="J_install_tip_dbhost"><span class="gray">一般为 localhost 或 127.0.0.1</span></div></td>
          </tr>
     
          <tr>
              <td class="tar">数据库名</td>
              <td><input type="text" type="text" name="DB_NAME" required lay-verify="required" autocomplete="off" class="input" ><div id="J_install_tip_dbname"></div></td>
            </tr>
          <tr>
            <td class="tar">数据库账号</td>
            <td><input type="text" name="DB_USER" required lay-verify="required" autocomplete="off" class="input"><div id="J_install_tip_dbuser"></div></td>
          </tr>
          <tr>
            <td class="tar">数据库密码</td>
            <td><input type="password" name="DB_PWD" required lay-verify="required" autocomplete="off" class="input"><div id="J_install_tip_dbpw"></div></td>
          </tr>
          <tr>
              <td class="tar">数据库端口</td>
              <td><input type="text" name="DB_PORT" value="3306" autocomplete="off" class="input"><div id="J_install_tip_dbport"><span class="gray">一般为3306</span></div>
			  <a class="btn_a" id="checkDb" href="javascript:;" style="margin-top:10px;"  lay-filter="formDemo" style="line-height:33px;height:33px;" >测试连接</a>
			  </td>
            </tr>
          <tr>
            <td class="tar">数据库表前缀</td>
            <td><input type="text" name="DB_PREFIX" value="<?php echo DB_PREFIX;?>" required lay-verify="required" autocomplete="off"  class="input" ><div id="J_install_tip_dbprefix"><span class="gray">推荐使用&nbsp;<?php echo DB_PREFIX;?></span></div></td>
          </tr>
        </table>
       
        <table width="100%" id="table" border="0" cellspacing="1" cellpadding="4">
          <tr>
            <td class="td1" colspan="2">管理员信息</td>
          </tr>
          <tr>
            <td class="tar">管理员帐号</td>
            <td><input type="text" name="admin_user" required lay-verify="required" autocomplete="off" class="input"><div id="J_install_tip_manager"><span class="gray">至少包含4个字符，需以字母开头</span></div></td>
          </tr>
          <tr>
            <td class="tar">管理员密码</td>
            <td><input type="password" name="admin_pass"  required lay-verify="required" autocomplete="off"  class="input"><div id="J_install_tip_manager_pwd"></div></td>
          </tr>
          <tr>
            <td class="tar">请确认密码</td>
            <td><input type="password" name="admin_pass2" required lay-verify="required" autocomplete="off" class="input" ><div id="J_install_tip_manager_ckpwd"></div></td>
          </tr>
          <tr>
            <td class="tar">安全验证码</td>
            <td><input type="text" name="code"   placeholder="选填"  autocomplete="off" class="input" ><div ><span class="gray">后台登录安全码。与验证码搭配可有效阻止试探登录者。最多8位</span></div></td>
          </tr>
            <tr>
                <td class="tar">UpdateKey</td>
                <td><input type="text" name="updatekey" placeholder="32位"  autocomplete="off" class="input" ><div id="J_install_tip_manager_ckkey"><span class="gray">去<a target="LaySNS应用中心查看" href="https://bbs.laysns.com/apps/developer/myupkey.html">LaySNS应用中心</a>查看</span></div></td>
            </tr>
        </table>
        <div id="J_response_tips" style="display:none;"></div>
      </div>
      <div class="blank20"></div>
      <div class="bottom tac">
        <center>
        <a href="./index.php?c=test" class="btn_b">上一步</a>
		<input class="btn_a" type="submit" lay-submit lay-filter="formDemo" style="line-height:33px;height:33px;" value="确认安装">
        </center>
      </div>
      <div class="blank20"></div>
    </form>
  </section>
  <div  style="width:0;height:0;overflow:hidden;"> <img src="./images/pop_loading.gif"> </div>
</div>
 <div class="blank20"></div>
<div class="footer"> Powered by  <a href="http://www.laysns.com" target="_blank">LAYSNS</a></div>
</body>
<script>
 $("#checkDb").on("click",function(){
    var arr = $('form').serializeArray();
        console.log(arr);
        var tempObj = {};
        $.each(arr, function (i, obj) {
            tempObj[obj.name] = obj.value;
        });
		if(tempObj.DB_HOST==''||tempObj.DB_USER==''||tempObj.DB_PWD==''){
		  alert('数据库的地址、账号、密码均为必填项');
		  return false;
		}
		$.post("./index.php?c=test_db",
            tempObj
            , function (rs) {
               
                    alert(rs);
                
            });
 });
</script>
</html>